package com.easy.system.service.impl;

import com.easy.system.dao.BaseDao;
import com.easy.system.service.BaseService;
import com.easy.system.util.Condition;
import com.easy.system.util.Pagination;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sunguangzhu
 * Date: 13-7-1
 * Time: 下午2:53
 * To change this template use File | Settings | File Templates.
 */
@Service
public class BaseServiceImpl<T> implements BaseService<T> {
    @Resource
    private BaseDao<T> baseDao;


    @Override
    public void save(T entity) {
        //To change body of implemented methods use File | Settings | File Templates.
        this.baseDao.save(entity);
    }

   /* @Override
    public List find(String queryString) {
        return this.baseDao.find(queryString);  //To change body of implemented methods use File | Settings | File Templates.
    }*/

    @Override
    public T get(Class<T> clazz, Long id) {
        return this.get(clazz, id);  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void update(T entity) {
        this.baseDao.update(entity);
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void delete(Class<T> clazz, Long id) {
        T entity = this.baseDao.get(clazz, id);
        this.baseDao.delete(entity);
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int delete(Class<T> clazz, String ids) {
        return this.baseDao.delete(clazz, ids);
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<T> find(Pagination pagination) {
        return this.find(null, pagination);
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<T> find(Condition condition) {
        return this.find(condition, null);
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<T> find(Condition condition, Pagination pagination) {
        return this.baseDao.find(condition, pagination);
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public Long getTotal(Class<T> clazz) {
        return this.baseDao.getTotal(clazz);  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public Long getTotal(Condition condition) {
        return this.baseDao.getTotal(condition);  //To change body of implemented methods use File | Settings | File Templates.
    }
}
